﻿using STHPMS1.DAL.D_Core;
using System.Data;
using ServiceStack.OrmLite;
using STHPMS1.ICore.I_Entity.Stmpms1;
using STHPMS1.Common.C_Entity.Stmpms1;
using STHPMS1.ICore.I_DAL.Repository;
using System.Collections.Generic;
using System.Data.SqlClient;

namespace STHPMS1.DAL.D_Repository
{
    public class Dp_Dailymain_CostRepository : DalBase, IDp_Dailymain_CostRepository
    {

        /// <summary>
        /// 通过决策路段获取基础路段信息
        /// </summary>
        /// <param name="mainsegid"></param>
        /// <returns></returns>
        public IB_Invntory GetB_Invntory(string mainsegid)
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select B_INVNTORY.* from B_INVNTORY inner join DN_DIVI_RESULT on B_INVNTORY.SEGID=DN_DIVI_RESULT.SEGID where DN_DIVI_RESULT.MAINSEGID='" + mainsegid + "'";
            return conn.Single<B_Invntory>(strsql);
            
        }

        /// <summary>
        /// 通过决策路段获取基础路段信息
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="rdwayid">路线编号</param>
        /// <param name="segid_main">养护类型</param>
        /// <returns></returns>
        public List<T> GetB_Invntory<T>(string rdwayid, int segid_main) where T : class,IB_Invntory
        {
            IDbConnection conn = Adapter.OpenDbConnection();
            string strsql = "select B_INVNTORY.* from B_INVNTORY inner join DN_DIVI_RESULT on B_INVNTORY.SEGID=DN_DIVI_RESULT.SEGID where DN_DIVI_RESULT.RDWAYID='" + rdwayid + "' AND DN_DIVI_RESULT.SEGID_MAIN=" + segid_main + "";
            return conn.Select<T>(strsql);
        }
    }
}
